package com.htx.zqs.blesmartmask.custom;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;

import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.utils.MPPointF;

/**
 * Created by Administrator on 2018/7/17.
 */

public class MpLineChart  extends LineChart{
    public MpLineChart(Context context) {
        super(context);
    }

    public MpLineChart(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MpLineChart(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }
    protected void drawDescription(Canvas c) {
        // check if description should be drawn
        if (mDescription != null && mDescription.isEnabled()) {
            MPPointF position = mDescription.getPosition();

            mDescPaint.setTypeface(mDescription.getTypeface());
            mDescPaint.setTextSize(mDescription.getTextSize());
            mDescPaint.setColor(mDescription.getTextColor());
            mDescPaint.setTextAlign(mDescription.getTextAlign());

            float x, y;

            // if no position specified, draw on default position
            if (position == null) {
                x = (mViewPortHandler.offsetLeft() + mDescription.getXOffset())*2 + 35;   ///-----ps 转dp
                Log.e("============",mViewPortHandler.offsetLeft()+"===="+mDescription.getXOffset()+"========"+mDescription.getTextSize());
                //  x = getWidth() - mViewPortHandler.offsetRight() - mDescription.getXOffset();
                Log.e("============",getWidth()+"===="+mViewPortHandler.offsetRight()+"========"+mDescription.getXOffset());
                // y = mDescription.getTextSize() + mViewPortHandler.offsetTop() + mDescription.getYOffset();
                y = getHeight() - mViewPortHandler.offsetBottom() - mDescription.getYOffset() - 30;
            } else {
                x = position.x;
                y = position.y;
            }
            c.drawText(mDescription.getText(), x, y, mDescPaint);
        }
    }
}
